package com.week2.day01;

import java.util.Random;

public class Hero {                   //英雄类
    private String name;              //英雄名字
    private int power;                //力量值
    private int agile;                //敏捷值
    private int intelligence;         //智力值

    public Hero() {                   //空参构造，使用默认数据
        this.name = "soldier76";
        this.power = 70;
        this.agile = 50;
        this.intelligence = 50;
    }

    public Hero(String name) {          //单参构造，只有名字
        this.name = name;
    }

    public Hero(String name, int power, int agile, int intelligence) {          //全参构造，共4个参数
        this.name = name;
        this.power = power;
        this.agile = agile;
        this.intelligence = intelligence;
    }

    //set and get 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public int getAgile() {
        return agile;
    }

    public void setAgile(int agile) {
        this.agile = agile;
    }

    public int getIntelligence() {
        return intelligence;
    }

    public void setIntelligence(int intelligence) {
        this.intelligence = intelligence;
    }

    public int normalAttack() {                      //普通攻击
        Random random = new Random();                //随机数对象
        int normalDamage = random.nextInt((int) (0.4 * getPower())) + ((int) (0.8 * getPower()));    //本次普攻基础伤害
        System.out.println("本次攻击，基础伤害为：" + normalDamage);
        return normalDamage;
    }

    @Override
    public String toString() {
        return "基础属性{" +
                "名字='" + name + '\'' +
                ", 力量=" + power +
                ", 敏捷=" + agile +
                ", 智力=" + intelligence +
                '}';
    }
}
